package com.xu.system.model.convert;

import com.xu.system.model.entity.SysWorkTimeConfig;
import com.xu.system.model.pojo.workTime.AddWorkTimeConfigReq;
import com.xu.system.model.pojo.workTime.SaveWorkTimeReq;
import com.xu.system.model.pojo.workTime.WorkTimeConfigBo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * 工作日配置对象转换器
 *
 * @Author: 许乾伟
 * @Date: 2024/12/24 15:44
 */
@Mapper(componentModel = "spring")
public interface WorkTimeConfigConvert {
    @Mappings({
            @Mapping(target = "noonBreakStartTime", expression = "java(com.xu.base.utils.LocalDateUtils.hhmmssToLocalTime(req.getNoonBreakStartTime()))"),
            @Mapping(target = "noonBreakEndTime", expression = "java(com.xu.base.utils.LocalDateUtils.hhmmssToLocalTime(req.getNoonBreakEndTime()))"),
            @Mapping(target = "workStartTime", expression = "java(com.xu.base.utils.LocalDateUtils.hhmmssToLocalTime(req.getWorkStartTime()))"),
            @Mapping(target = "workEndTime", expression = "java(com.xu.base.utils.LocalDateUtils.hhmmssToLocalTime(req.getWorkEndTime()))"),
            @Mapping(target = "createBy", expression = "java(com.xu.security.utils.SecurityUtils.getUserId())"),
            @Mapping(target = "createTime", expression = "java(java.time.LocalDateTime.now())"),
            @Mapping(target = "updateBy", expression = "java(com.xu.security.utils.SecurityUtils.getUserId())"),
            @Mapping(target = "updateTime", expression = "java(java.time.LocalDateTime.now())")
    })
    SysWorkTimeConfig toSysWorkTimeConfig(AddWorkTimeConfigReq req);

    WorkTimeConfigBo toWorkTimeConfigBo(SysWorkTimeConfig workTimeConfig);
}
